package deng.ejb3.examples.simplecase;

import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="SESSION_BREAK")
public class SessionBreak {
	
	public static enum BreakType {
		SMALL,
		LUNCH,
		MEETING,
		ERRAND,
		NONE
	}

	@Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="SESSION_BREAK_ID")
	private Long id;
	
	@ManyToOne
	@JoinColumn(name="WORK_SESSION_ID")
	private WorkSession workSession;
	
	@Enumerated(EnumType.STRING)
    @Column(name="BREAK_TYPE")
	private BreakType breakType;

    @Column(name="START_TIME")
	private Timestamp startTime;

    @Column(name="STOP_TIME")
	private Timestamp stopTime;
	
	@Override
	public String toString() {
		String sessionId = workSession == null ? "null" : "" + workSession.getId();
		return "SessionBreak(id=" + id + ", workSession.id=" + sessionId 
			+ ", breakType=" + breakType
			+ ", startTime=" + startTime + ", stopTime=" + stopTime + ")";
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public void setBreakType(BreakType breakType) {
		this.breakType = breakType;
	}
	
	public BreakType getBreakType() {
		return breakType;
	}

	public Timestamp getStartTime() {
		return startTime;
	}

	public void setStartTime(Timestamp startTime) {
		this.startTime = startTime;
	}

	public Timestamp getStopTime() {
		return stopTime;
	}

	public void setStopTime(Timestamp stopTime) {
		this.stopTime = stopTime;
	}
	
}
